package com.servlet.rootoperator;

import com.Impl.BookCRUD;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "ClearAllBooksServlet", value = "/ClearAllBooksServlet")
public class ClearAllBooksServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        在这里面写清空所有数据的业务
        BookCRUD bookCRUD = new BookCRUD();
        int count = bookCRUD.clearAllBooks();
        System.out.println("删除了"+count+"条数据");
        response.getWriter().println(count);
    }
}
